home *** CD-ROM | disk | FTP | other *** search
- /**
- * Scout - The Amiga System Monitor
- *
- *------------------------------------------------------------------
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- * You must not use this source code to gain profit of any kind!
- *
- *------------------------------------------------------------------
- *
- * @author Andreas Gelhausen
- * @author Richard Körber <rkoerber@gmx.de>
- */
-
-
-
- #include "scout_classes.h"
-
- extern struct ExecBase *SysBase;
-
- int classcnt;
-
- APTR classmoretext0,classmoretext1,classmoretext2,classmoretext3,classmoretext4;
-
- struct Remember *ClassRememberKey;
-
- __asm LONG classlist_dspfunc(register __a2 char **array, register __a1 struct ClassEntry *classentry, register __a0 struct Hook *hook) {
- if (classentry) {
- *array++ = classentry->cse_address;
- *array++ = classentry->cse_objcnt;
- *array++ = classentry->cse_subcnt;
- *array++ = classentry->cse_super;
- *array++ = classentry->cse_dispatch;
- *array = classentry->cse_classname;
- } else {
- *array++ = ESC "bAddress";
- *array++ = ESC "bObjects";
- *array++ = ESC "bSubclasses";
- *array++ = ESC "bSuperclass";
- *array++ = ESC "bDispatcher";
- *array = ESC "bName";
- }
- return (0);
- }
-
- struct Hook classlist_dsphook = {
- {NULL, NULL},
- (ULONG (* )())classlist_dspfunc,
- NULL, NULL
- };
-
- void FFreeClass (void) {
- MyFreeStructs (&ClassRememberKey, classtext, classlist);
- }
-
- int GetClass (struct ClassEntry **first) {
- struct ClassEntry *classentry,*previous = NULL;
-
- int classcnt = 0;
- *first = 0;
-
- if (clientstate) {
- if (SendDaemon ("GetClassList")) {
- while ((classentry = AllocRemember (&ClassRememberKey, sizeof (struct ClassEntry), MEMF_ANY|MEMF_CLEAR)) \
- && (ReceiveDecodedEntry ((UBYTE *) classentry, sizeof (struct ClassEntry)))) {
- IsHex (classentry->cse_address, (long *) &classentry->cse_adr);
-
- if (! *first)
- *first = classentry;
- if (previous)
- previous->cse_next = classentry;
-
- classcnt++;
- previous = classentry;
- }
- }
- } else {
- struct IClass *myclass = MakeClass("« Scout Dummy Class »","rootclass",NULL,0,0);
- struct Node *clist;
- struct Hook *disp;
-
- if(myclass) {
- AddClass(myclass);
- Forbid();
- for(clist=(struct Node *)&myclass->cl_Dispatcher.h_MinNode; clist->ln_Pred; clist=clist->ln_Pred); /* Search the list head */
- for(clist=clist->ln_Succ; clist->ln_Succ; clist=clist->ln_Succ) {
- if(clist==(struct Node *)myclass) continue; /* Skip own dummy */
- if(classentry = AllocRemember (&ClassRememberKey, sizeof(struct ClassEntry), MEMF_ANY|MEMF_CLEAR)) {
-
- disp = &((struct IClass *)clist)->cl_Dispatcher;
-
- classentry->cse_adr = (struct IClass *)clist;
- sprintf(classentry->cse_address,"$%08lx",clist);
- sprintf(classentry->cse_super,"$%08lx",((struct IClass *)clist)->cl_Super);
- sprintf(classentry->cse_dispatch,"$%08lx",(disp->h_SubEntry ? disp->h_SubEntry : disp->h_Entry));
- strncpy(classentry->cse_classname,((struct IClass *)clist)->cl_ID,79);
- sprintf(classentry->cse_objcnt,"%ld",((struct IClass *)clist)->cl_ObjectCount);
- sprintf(classentry->cse_subcnt,"%ld",((struct IClass *)clist)->cl_SubclassCount);
-
- if (! *first)
- *first = classentry;
- if (previous)
- previous->cse_next = classentry;
- classcnt++;
- previous = classentry;
- }
- }
- Permit();
- FreeClass(myclass);
- }
- }
- return (classcnt);
- }
-
- void PrintClass (char *filename) {
- int i=1;
- BPTR handle;
- struct ClassEntry *entryp;
-
- handle = HandlePrintStart (filename);
- if ((handle) && (PrintOneLine (handle, "\n Address Objects Subclasses Superclass Dispatcher Name\n\n"))) {
- if (! WI_Class) {
- i = GetClass (&entryp);
- }
- if (i) {
- for (i=0;;i++) {
- if (WI_Class)
- DoMethod (classlist,MUIM_List_GetEntry,i,&entryp);
- if (!entryp) break;
-
- sprintf (tmpstr2, " %ls %7ls %11ls %ls %ls %ls\n", entryp->cse_address, entryp->cse_objcnt, entryp->cse_subcnt, entryp->cse_super, entryp->cse_dispatch, entryp->cse_classname);
- if (! (PrintOneLine (handle, tmpstr2)))
- break;
-
- if (! WI_Class)
- entryp = entryp->cse_next;
- }
- }
- }
- HandlePrintStop();
- }
-
- void ShowClass (void) {
- struct ClassEntry *clas;
-
- ApplicationSleep();
- set(classlist,MUIA_List_Quiet,TRUE);
- set(classlist,MUIA_List_CompareHook,classlist_cmphook_ptr);
- set(BT_ClassRemove, MUIA_Disabled, TRUE);
- set(BT_ClassMore, MUIA_Disabled, TRUE);
- FFreeClass();
-
- classcnt = GetClass (&clas);
-
- while (clas) {
- InsertSortedEntry (classlist, (APTR *) &clas);
- clas = clas->cse_next;
- }
-
- SetCountText (classcount, classcnt);
- AwakeApplication();
- set(classlist,MUIA_List_Quiet,FALSE);
- }
-
- void SendClassList (void) {
- struct ClassEntry *clas;
-
- FFreeClass();
- GetClass (&clas);
-
- while (clas) {
- SendEncodedEntry ((UBYTE *) clas, sizeof (struct ClassEntry));
- clas = clas->cse_next;
- }
- FFreeClass();
- }
-
- void GetClassMore (struct IClass *bc) {
- unsigned char *title = "CLASS: ";
- struct WinFree *ptr;
- BOOL found = FALSE;
- struct IClass *myclass = MakeClass("« Scout Dummy Class »","rootclass",NULL,0,0);
- struct Node *clist;
-
- if(myclass) {
- AddClass(myclass);
- Forbid();
- for(clist=(struct Node *)&myclass->cl_Dispatcher.h_MinNode; clist->ln_Pred; clist=clist->ln_Pred); /* Search the list head */
- for(clist=clist->ln_Succ; clist->ln_Succ; clist=clist->ln_Succ) {
- if(clist==(struct Node *)myclass) continue; /* Skip own dummy */
- if(clist==(struct Node *)bc) {
- found = TRUE;
- break;
- }
- }
- Permit();
- FreeClass(myclass);
- }
-
- if (found && (ptr = AllocWinFree())) {
- ptr->wf_Window = (APTR) WindowObject,
- MUIA_HelpNode, ClassesText,
- MUIA_Window_ID, MakeDetailID('.','C','L','S'),
- WindowContents, VGroup,
- Child, ColGroup(2),
- Child, MyLabel2 ("Name:"),
- Child, classmoretext0 = MyTextObject(),
- Child, MyLabel2 ("Super:"),
- Child, classmoretext1 = MyTextObject(),
- End,
- Child, HGroup,
- Child, MyLabel2 ("Address:\nSuper:\nInstOffset:\nInstSize:"),
- Child, classmoretext2 = MyTextObject2(),
- Child, HSpace(0),
- Child, MyLabel2 ("Entry:\nSubEntry:\nData:\nUserData:"),
- Child, classmoretext3 = MyTextObject2(),
- Child, HSpace(0),
- Child, MyLabel2 ("SubClasses:\nObjects:\nFlags:\nReserved:"),
- Child, classmoretext4 = MyTextObject2(),
- End,
- End, End;
-
- if (ptr->wf_Window) {
- MySetContentsHealed (classmoretext0, "%s", bc->cl_ID);
- MySetContentsHealed (classmoretext1, "%s", bc->cl_Super ? bc->cl_Super->cl_ID : (STRPTR)"---");
- MySetContents (classmoretext2, ESC "r$%08x\n" ESC "r$%08lx\n" ESC "r%ld\n" ESC "r%ld", bc, bc->cl_Super, bc->cl_InstOffset, bc->cl_InstSize);
- MySetContents (classmoretext3, ESC "r$%08x\n" ESC "r$%08lx\n" ESC "r$%08lx\n" ESC "r$%08lx", bc->cl_Dispatcher.h_Entry, bc->cl_Dispatcher.h_SubEntry, bc->cl_Dispatcher.h_Data, bc->cl_UserData);
- MySetContents (classmoretext4, ESC "r%ld\n" ESC "r%ld\n" ESC "r$%08lx\n" ESC "r$%08lx", bc->cl_SubclassCount, bc->cl_ObjectCount, bc->cl_Flags, bc->cl_Reserved);
-
- //* HandleFlagsButtonPressed (classmoretext4, ptr, "(COMMODITY)", "Flags", bc->mco_Flags, (struct LongFlag *) &bc_flags, NULL, 'b');
- HandleWindowOpen (ptr, title, bc->cl_ID);
- HandleWindowClose (ptr);
- }
- }
- }
-
-